import { Map } from "immutable";

import {
    CHANGE_CATEGORY,
    CHANGE_CATEGORY_SONGS,
    CHANGE_CURRENT_CATEGORY
} from "./constants"

const defaultState = Map({
    category: [],//下拉的分类数据
    currentCategory: "全部", //当前选择的分类
    categorySongs: {},//该分类下的歌手列表 及总数  categorySongs
})


function reducer (state = defaultState, action) {
    switch (action.type) {
        case CHANGE_CATEGORY:
            return state.set("category", action.categoryList);
        
        case CHANGE_CURRENT_CATEGORY:
            return state.set("currentCategory", action.currentCategory);// currentCategory

        case CHANGE_CATEGORY_SONGS:
            return state.set("categorySongs", action.categorySongs);
            
    
        default:
            return state;
    }
}

export default reducer;